﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Seta;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;

namespace Listas
{
    public enum PositionType
    {
        X1,
        X2
    }
    public class Arrows : CommomFunctions.Arrows
    {
        ArrowLine arrowNull = new ArrowLine();
        private static int numArrows = 7;
        ArrayList positionsX1 = new ArrayList();
        ArrayList positionsX2 = new ArrayList();
        

        public Arrows()
        {

        }

        public void createArrows(Grid Gridi)
        {
            for (int i = 0; i < numArrows; i++)
            {
                ArrowLine tempArrow = new ArrowLine();
                Gridi.Children.Add(tempArrow);
                arrows.Add(tempArrow);
            }

            foreach (ArrowLine a in arrows)
            {
                a.Stroke = Brushes.DarkSeaGreen;
                a.StrokeThickness = 3.0;
                a.VerticalAlignment = VerticalAlignment.Center;
                a.Y1 = 85;
                a.Y2 = 85;
                a.Visibility = Visibility.Hidden;
                Grid.SetRow(a, 1);
                Grid.SetRowSpan(a, 2);
                Grid.SetColumnSpan(a, 9);
            }
        }


        internal ArrowLine getArrow(int p)
        {
            return ((ArrowLine)arrows[p]);
        }

        internal void fillX1X2Positions(ArrayList labels, bool primeira)
        {
            for (int i = 0; i < numArrows; i++)
             {
                 ((ArrowLine)arrows[i]).X1 = 994 - ((Label)labels[i]).Margin.Right;
                 ((ArrowLine)arrows[i]).X2 = ((Label)labels[i + 1]).Margin.Left;
             }
             if (primeira)
             {
                 primeira = false;
                 for (int i = 0; i < numArrows; i++)
                 {
                     positionsX1.Add(((ArrowLine)arrows[i]).X1);
                     positionsX2.Add(((ArrowLine)arrows[i]).X2);
                 }
             }
        }

        internal double getArrowPosition(PositionType positionType, int i)
        {
            switch (positionType)
            {
                case PositionType.X1: return (double)positionsX1[i];
                case PositionType.X2: return (double)positionsX2[i];
            }
            return 0;
        }
    }
}
